package ase.eleitweg.server;

import java.rmi.*;
import java.util.*;

import com.google.inject.ImplementedBy;

import ase.eleitweg.common.*;

@ImplementedBy(WorkflowController.class)
public interface WorkflowManager extends Remote {

	/**
	 * Adds a workflow to the DB. All Nodes, Edges and Conditions must have
	 * id=0. The referenced Groups must already be stored in the DB before
	 * calling this function.
	 * 
	 * @param w
	 * @throws RemoteException
	 */
	public int addWorkflow(Workflow w) throws RemoteException;

	/**
	 * Returns all Workflows from Database
	 * 
	 * @return
	 * @throws RemoteException
	 */
	public List<Workflow> getWorkflows() throws RemoteException;

	/**
	 * Creates a copy of the Workflow - all nodes and edges are copied, the referenced groups stay identical.
	 * IDs of all objects (workflow, nodes, edges, groups) must be !=0
	 * Afterwards the new copy is stored in the DB.
	 * @param w
	 * @return
	 */
	public Workflow copyWorkflow(Workflow w) throws RemoteException;

	/**
	 * Removes given workflow and all its nodes and edges form DB.
	 * @param w
	 */
	public void deleteWorkflow(Workflow w) throws RemoteException;
	
	/**
	 * Updates a given workflow. Only title, description and date get updated. Changes to the structure are ignored.
	 * @param w
	 */
	public void updateWorkflow(Workflow w) throws RemoteException;
	
	public Workflow getWorkflow(int id) throws RemoteException;

}
